package com.nulldev.util.crypto.encryptAPI.manage;

import com.nulldev.util.other.ArrayUtils;
import com.nulldev.util.string.StringsUtil;

public class EncryptUtilDemo {

	public static void main(String[] args) {
		final String[] encryptors = EncryptAPI.getEncryptors();
		ArrayUtils.println("Encryptors on nullUtil:", encryptors);
		System.out.println("Testing system....");
		System.out.println("Note: 'default' should return false.");
		for (final String encryptor : encryptors) {
			System.out.println(encryptor + "..." + EncryptAPI.isEncryptorByID(encryptor));
		}
		final Encryptor xorOneTime = EncryptAPI.getEncryptorForEncryption("DualXOR");
		if (EncryptAPI.isDefault(xorOneTime)) {
			System.err.println("No encryption applied!");
			return;
		}
		System.out.println("Loaded Cipher: " + xorOneTime.getClass().getSimpleName());
		final String password = StringsUtil.randomString(32);
		final String in = xorOneTime.encrypt("testttttttttt", password);
		System.out.println(in);
		System.out.println(xorOneTime.decrypt(in, password));
	}

}
